<script setup lang="ts">
import { onMounted } from 'vue'
import { useUserStore } from '@/stores/user'

const userStore = useUserStore()

// 应用启动时获取用户信息和权限
onMounted(async () => {
  // 检查是否有token
  const userStr = localStorage.getItem('user')
  if (userStr) {
    try {
      const userData = JSON.parse(userStr)
      if (userData.token) {
        // 有token时获取用户信息和权限
        await userStore.fetchUserInfo()
      }
    } catch (error) {
      console.error('解析用户数据失败:', error)
    }
  }
})
</script>

<template>
  <router-view></router-view>
</template>

<style>
:root {
  --primary-color: #1890ff;
  --success-color: #52c41a;
  --warning-color: #faad14;
  --danger-color: #f5222d;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial,
    'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol',
    'Noto Color Emoji';
}

#app {
  height: 100%;
}

.ant-layout {
  background: #f0f2f5;
}

.ant-card {
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.ant-btn {
  border-radius: 4px;
}

.ant-input {
  border-radius: 4px;
}

.ant-menu {
  border-right: none;
}

.ant-layout-header {
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
}

.ant-layout-sider {
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.05);
}
</style>
